import request from '@/utils/request'


export default {
  getTestTitleList(searchModel) {
    return request({
      url: '/test/list',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize
      }
    })
  },
  getExamTitleList(searchModel) {
    return request({
      url: '/test/exam',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize
      }
    })
  },
  getExamHistoryList(searchModel) {
    return request({
      url: '/test/exam_history',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        key: searchModel.key,
        score: searchModel.score,
      }
    })
  },
  startTestById(id) {
    return request({
      // url: '/user' + id,
      url: `/test/${id}`,
      method: 'get',
    })
  },
  submitExam(exam) {
    return request({
      url: '/test',
      method: 'post',
      data: exam
    })
  },
  startExamById(id) {
    return request({
      // url: '/user' + id,
      url: `/test/exam/${id}`,
      method: 'get',
    })
  },
  submitFlyExam(exam) {
    return request({
      url: '/test/exam',
      method: 'post',
      data: exam
    })
  },
  getExamineeAnswerById(id) {
    return request({
      // url: '/user' + id,
      url: `/test/examinee/answer/${id}`,
      method: 'get',
    })
  },
  submitCorrection(exam) {
    return request({
      url: '/test/exam/correction',
      method: 'post',
      data: exam
    })
  },
  deleteExamById(id) {
    return request({
      // url: '/user' + id,
      url: `/test/exam/${id}`,
      method: 'delete',
    })
  },
  //获取科目相关接口
  getCourseList(searchModel) {
    return request({
      url: `/test/course`,
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        // username: searchModel.username,
        // phone: searchModel.phone
      }
    })
  },
  getCourseById(id) {
    return request({
      url: `/test/course/${id}`,
      method: 'get',
    })
  },
  addCourse(course) {
    return request({
      url: '/test/course',
      method: 'post',
      data: course
    })
  },
  updateCourse(course) {
    return request({
      url: '/test/course',
      method: 'put',
      data: course
    })
  },
  saveCourse(course) {
    if (course.id == null || course.id == undefined) {
      return this.addCourse(course);
    }
    return this.updateCourse(course);
  },
  deleteCourseById(id) {
    return request({
      // url: '/user' + id,
      url: `/test/course/${id}`,
      method: 'delete',
    })
  },

  //获取试卷相关接口
  getPaperList(searchModel) {
    return request({
      url: `/test/paper`,
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        // username: searchModel.username,
        // phone: searchModel.phone
      }
    })
  },
  getPaperById(id) {
    return request({
      url: `/test/paper/${id}`,
      method: 'get',
    })
  },
  addPaper(paper) {
    return request({
      url: '/test/paper',
      method: 'post',
      data: paper
    })
  },
  updatePaper(paper) {
    return request({
      url: '/test/paper',
      method: 'put',
      data: paper
    })
  },
  savePaper(paper) {
    if (paper.id == null || paper.id == undefined) {
      return this.addPaper(paper);
    }
    return this.updatePaper(paper);
  },
  deletePaperById(id) {
    return request({
      // url: '/user' + id,
      url: `/test/paper/${id}`,
      method: 'delete',
    })
  },

  //获取试卷详情相关接口
  getFpdList(searchModel) {
    return request({
      url: `/test/Fpd`,
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        // username: searchModel.username,
        // phone: searchModel.phone
      }
    })
  },
  getFpdById(id) {
    return request({
      url: `/test/Fpd/${id}`,
      method: 'get',
    })
  },
  addFpd(Fpd) {
    return request({
      url: '/test/Fpd',
      method: 'post',
      data: Fpd
    })
  },
  updateFpd(Fpd) {
    return request({
      url: '/test/Fpd',
      method: 'put',
      data: Fpd
    })
  },
  saveFpd(Fpd) {
    if (Fpd.id == null || Fpd.id == undefined) {
      return this.addFpd(Fpd);
    }
    return this.updateFpd(Fpd);
  },
  deleteFpdById(id) {
    return request({
      // url: '/user' + id,
      url: `/test/Fpd/${id}`,
      method: 'delete',
    })
  },

  //获取题库详情相关接口
  getQuestionList(searchModel) {
    return request({
      url: `/test/Question`,
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        course_id: searchModel.course_id,
        question_type: searchModel.question_type,
        question_id: searchModel.question_id,
        key: searchModel.key,
      }
    })
  },
  getQuestionById(id) {
    return request({
      url: `/test/Question/${id}`,
      method: 'get',
    })
  },
  addQuestion(Question) {
    return request({
      url: '/test/Question',
      method: 'post',
      data: Question
    })
  },
  updateQuestion(Question) {
    return request({
      url: '/test/Question',
      method: 'put',
      data: Question
    })
  },
  saveQuestion(Question) {
    if (Question.id == null || Question.id == undefined) {
      return this.addQuestion(Question);
    }
    return this.updateQuestion(Question);
  },
  deleteQuestionById(id) {
    return request({
      // url: '/user' + id,
      url: `/test/Question/${id}`,
      method: 'delete',
    })
  },

  //批量更新上传题库
  mutliUpload(param) {
    return request({
      url: `/test/Question/mutliUpload`,
      method: 'post',
      data: param,
    })
  },
  // 下载模板
  downloadTemplate() {
    return request({
      url: `/test/Question/downloadTemplate`,
      method: 'get',
      // responseType: 'blob',
    })
  },
  download(searchModel) {
    return request({
      url: `/test/Question/download`,
      method: 'get',
      params: {
        course_id: searchModel.course_id,
        question_type: searchModel.question_type,
        question_id: searchModel.question_id,
        key: searchModel.key,
      }
    })
  }
}
